const state = {
  notices: null,
  taskReceiveingNum: 0, // 福利等待领取的数量
  invitationScoreNum: 0, // 推广积分等待领取的数量
  messageNotReadNum: 0, // 未读消息数量
};

const actions = {};

const mutations = {
  noticesUpdate(state, data) {
    if (data.content) {
      state.notices = data;
    }
  },

  task_receiveing(state, data) {
    // 设置福利等待领取的数量
    state.taskReceiveingNum = data.task;
    // 设置推广等待领取积分的数量
    state.invitationScoreNum = data.invite;
    if (Number(data.task) > 0) {
      uni.setTabBarBadge({
        index: 2,
        text: data.task.toString()
      })
    } else {
      uni.removeTabBarBadge({
        index: 2
      });
    }
    if (Number(data.invite) > 0) {
      uni.setTabBarBadge({
        index: 1,
        text: data.invite.toString()
      });
    } else {
      uni.removeTabBarBadge({
        index: 1
      });
    }
  },
  // 设置推广等待领取积分的数量

  // 设置消息带读的数量
  message_notread_num(state, data) {
    state.messageNotReadNum = data.num;
  },
}
export default {
  namespaced: true,
  state,
  actions,
  mutations
};
